//package com.pengzy.core.cloud_security;
//
//
//
//import com.alibaba.fastjson.annotation.JSONField;
//import com.fasterxml.jackson.annotation.JsonIgnore;
//import com.pengzy.supports.dto.UserDetail;
//import lombok.*;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.User;
//
//import java.io.Serializable;
//import java.util.Collection;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * @author xiaozhi 2023/7/17
// */
//
//@Getter
//@Setter
//public class SecurityUserDetails extends User implements Serializable {
//
//    private Long userId;
//
//    private UserDetail userDetail;
//
//    private String username;
//
//    @JsonIgnore
//    private String password;
//
//    //存储权限信息
//    private List<String> permissions;
//
//    //存储SpringSecurity所需要的权限信息的集合
//    @JSONField(serialize = false)
//    @JsonIgnore
//    private List<GrantedAuthority> authorities;
//
//    private String token;
//
//
//
//    public SecurityUserDetails(UserDetail userDetail,String username, String password, Collection<? extends GrantedAuthority> authorities) {
//        super(username, password, authorities);
//        this.userDetail = userDetail;
//    }
//
//    public SecurityUserDetails(String username, String password, Collection<? extends GrantedAuthority> authorities, Long userId) {
//        super(username, password, authorities);
//        this.userId = userId;
//    }
//
//    public SecurityUserDetails(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, Long userId) {
//        super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
//        this.userId = userId;
//    }
//
//
//    @Override
//    public Collection<GrantedAuthority> getAuthorities() {
//        if(permissions==null){
//            return null;
//        }
//        //把permissions中字符串类型的权限信息转换成GrantedAuthority对象存入authorities中
//        authorities = permissions.stream().
//                map(SimpleGrantedAuthority::new)
//                .collect(Collectors.toList());
//        return authorities;
//    }
//
//
//    public Long getUserId() {
//        return userId;
//    }
//
//    public void setUserId(Long userId) {
//        this.userId = userId;
//    }
//
//}
